package spring.cloud.tasks.common.nodepaths;

import spring.cloud.tasks.common.Symbols;

public final class TaskNodePaths {
    public static final String ROOT = Symbols.SLASH + "tasks";

    private TaskNodePaths() {
    }

    public static String getROOT() {
        return ROOT;
    }

    public static String getTaskNodePath(String taskId) {
        return getROOT() + Symbols.SLASH + taskId;
    }

    public static String getTaskNodePath(final String taskId, final String node) {
        return getTaskNodePath(taskId) + Symbols.SLASH + node;
    }

    public static String getTaskBaseInfoNodePath(final String taskId) {
        return getTaskNodePath(taskId, TaskBaseInfoNode.baseInfoNode);
    }

    public static String getTaskBaseInfoNodePath(final String taskId, final String nodeName) {
        return getTaskBaseInfoNodePath(taskId) + Symbols.SLASH + nodeName;
    }


    public static final String enabled = Symbols.SLASH + "enabled";
    public static final String status = "status";
    public static final String delete = Symbols.SLASH + "delete";//删除标志 只要这个被打上那么就不能再被启用
    public static final String to_delete = Symbols.SLASH + "to_delete";//尝试删除标志
    public static final String prefer_executor_id_list = "prefer_executor_id_list";

    //
    public static String getTaskExecutorsNodePath(final String taskId) {
        return getTaskNodePath(taskId, "executors");
    }

    public static String getTaskExecutorNodePath(final String taskId, final String executorId) {
        return getTaskExecutorsNodePath(taskId) + Symbols.SLASH + executorId;
    }

    public static String getTaskExecutorNodePath(final String taskId, final String executorId, final String nodeName) {
        return getTaskExecutorNodePath(taskId, executorId) + Symbols.SLASH + nodeName;
    }

    public static String getExecutorStatus(final String taskId, final String executorId) {
        return getTaskExecutorNodePath(taskId, executorId) + Symbols.SLASH + "status";
    }

    //
    public static final String TASKS_UPDATE_VERSION = Symbols.SLASH + "tasksUpdateVersion";

    public static String getTasksUpdateVersionNodePath() {
        return TASKS_UPDATE_VERSION;
    }
}
